#include "FileTest.h"
#include <stdio.h>
#include <string.h>

/*
 * Created: 2/27/12; CGP
a) Create a new file (opened for writing)
b) Close the file
c) List the files to make sure they appear in directory
d) Delete the file
e) List the file to make sure it doesn't appear in directory
 */

int main(int argc, char *argv[]) {
    int length;
    printf("Starting test...\n"); fflush(stdout);
    FileTest ft;
    const char *fileName1 = "DEST";
    File *f1;

    printf("Creating a file...\n");
    f1 = new File(fileName1, "w");

    if (! f1->Close()) {
        printf("ERROR: Could not close file\n");
    }
    delete f1;

    if (ft.dir->LookUp(fileName1) == NULL) {
        printf("ERROR: %s file is not present in directory\n", fileName1);
    }

    if (! File::Delete(fileName1)) {
        printf("ERROR: Could not delete file\n");
    } else {
        printf("SUCCESS: It seems we were able to delete the file!\n");
    }

    if (ft.dir->LookUp(fileName1) != NULL) {
        printf("ERROR: %s file is present in directory after deletion\n", fileName1);
    }
}





